/*
 * @Author: xuetao 3168581151@qq.com
 * @Date: 2025-02-20
 * @LastEditors: xuetao 3168581151@qq.com
 * @LastEditTime: 2025-03-13
 * @Description: 
 */
// // 未读消息数量 浮动气泡
import 'package:chat_client/utils/media_tools.dart';
import 'package:flutter/material.dart';

class FloatingFloating extends StatelessWidget {
  final LayerLink layerLink;
  final Function jumpTo;
  final int unreadCount;

  const FloatingFloating({
    super.key,
    required this.layerLink,
    required this.jumpTo,
    required this.unreadCount,
  });

  @override
  Widget build(BuildContext context) {
    final double dx = getMediaWidth(context) - 110.0;
    return CompositedTransformFollower(
      link: layerLink,
      showWhenUnlinked: false,
      offset: Offset(dx, -50), // 相对于输入框的偏移量
      child: GestureDetector(
        onTap: () => jumpTo(),
        child: Container(
          padding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
          decoration: BoxDecoration(
            color: Color(0xFF99A8F1),
            borderRadius: BorderRadius.circular(20),
            boxShadow: [
              BoxShadow(
                color: Colors.black12,
                blurRadius: 4,
              ),
            ],
          ),
          child: Text(
            '$unreadCount条新消息',
            style: TextStyle(color: Colors.white, fontSize: 14),
          ),
        ),
      ),
    );
  }
}
